import About from "@/components/About.vue";
import Layout from "@/layout/Index.vue";
import { RouteRecordRaw, createRouter, createWebHistory } from "vue-router";


// const routes: Array<RouteRecordRaw> = [
//     {
//         path: '/home',
//         component: Layout
//     },
//     {
//         path: '/about',
//         component: About
//     },
// ]
// 路由规则
const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        redirect: '/login',
        name: "/",
    },
    {
        path: '/login',
        component: () => import('@/views/login/login.vue'),
        name: "login",
    },
    {
        path: '/dashboard',
        component: Layout,
        redirect: '/dashboard',
        children: [
            {
                path: '/dashboard',
                component: () => import('@/layout/Dashboard.vue'),
                name: 'dashboard',
                meta: {
                    title: '首页',
                    icon: '#icondashboard'
                }
            }
        ]
    },
    {
        path: "/system",
        component: Layout,
        name: "system",
        meta: {
            title: "系统管理",
            icon: "Setting",
            roles: ["sys:manage"],
        },
        children: [
            {
                path: "/adminUser",
                component: () => import('@/views/system/AdminUser.vue'),
                name: "adminUser",
                meta: {
                    title: "管理员管理",
                    icon: "UserFilled",
                    roles: ["sys:adminUser"],
                },
            },
            {
                path: "/userList",
                component: () => import('@/views/system/UserList.vue'),
                name: "userList",
                meta: {
                    title: "用户管理",
                    icon: "Wallet",
                    roles: ["sys:userList"],
                },
            },
            {
                path: "/menuList",
                component: () => import('@/views/system/MenuList.vue'),
                name: "menuList",
                meta: {
                    title: "菜单管理",
                    icon: "Menu",
                    roles: ["sys:menu"],
                },
            },
        ],
    },
    {
        path: "/goodsRoot",
        component: Layout,
        name: "goodsRoot",
        meta: {
            title: "商品管理",
            icon: "Setting",
            roles: ["sys:goodsRoot"],
        },
        children: [
            {
                path: "/goodsType",
                component: () => import('@/views/goods/GoodsType.vue'),
                name: "goodsType",
                meta: {
                    title: "商品分类",
                    icon: "UserFilled",
                    roles: ["sys:goodsType"],
                },
            },
            {
                path: "/unusedList",
                component: () => import('@/views/goods/UnusedList.vue'),
                name: "unusedList",
                meta: {
                    title: "闲置商品",
                    icon: "Wallet",
                    roles: ["sys:unusedList"],
                },
            },
            {
                path: "/buyList",
                component: () => import('@/views/goods/BuyList.vue'),
                name: "buyList",
                meta: {
                    title: "求购商品",
                    icon: "Wallet",
                    roles: ["sys:buyList"],
                },
            },
        ],
    },
    {
        path: "/order",
        component: Layout,
        name: "order",
        meta: {
            title: "订单管理",
            icon: "Setting",
            roles: ["sys:order"],
        },
        children: [
            {
                path: "/unusedOrder",
                component: () => import('@/views/order/UnusedOrder.vue'),
                name: "unusedOrder",
                meta: {
                    title: "闲置订单",
                    icon: "UserFilled",
                    roles: ["sys:unusedOrder"],
                },
            },
            {
                path: "/buyOrder",
                component: () => import('@/views/order/BuyOrder.vue'),
                name: "buyOrder",
                meta: {
                    title: "求购订单",
                    icon: "Wallet",
                    roles: ["sys:buyOrder"],
                },
            },
        ],
    },
    {
        path: "/comment",
        component: Layout,
        name: "comment",
        meta: {
            title: "评论管理",
            icon: "Setting",
            roles: ["sys:comment"],
        },
        children: [
            {
                path: "/commentList",
                component: () => import('@/views/comment/CommentList.vue'),
                name: "commentList",
                meta: {
                    title: "评论列表",
                    icon: "UserFilled",
                    roles: ["sys:commentList"],
                },
            },
        ],
    }
]

const router = createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    history: createWebHistory(),
    routes, // `routes: routes` 的缩写
})

export default router